package com.fly.chapter1;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by SWan on 2017/6/19.
 */
public class TimerServerHandlerExecutePool {

    private ExecutorService executorService;

    public TimerServerHandlerExecutePool(int maxPoolSize,int queueSize) {

        executorService = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),maxPoolSize,
                120L, TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(queueSize));

    }

    public void execute(Runnable task){
        executorService.execute(task);
    }
}
